package com.trdcore.zyzkt.controller;


import com.trdcore.zyzkt.model.vod.Subject;
import com.trdcore.zyzkt.resp.ResultData;
import com.trdcore.zyzkt.service.SubjectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Luffy
 * @since 2024-03-17
 */
@RestController
@RequestMapping("/admin/vod/subject")

@Tag(name = "课程科目接口")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    //课程分类列表
    //懒加载，每次只查一层数据
    @GetMapping("/getChildSubject/{id}")
    @Operation(summary = "课程分类列表",description = "课程分类列表")
    public ResultData getChildSubject(@PathVariable("id") Long id){
        List<Subject> list= subjectService.selectSubjectList(id);
        return ResultData.success(list);
    }

    @Operation(summary="导出课程列表",description = "导出课程列表")
    @GetMapping(value = "/exportData")
    public void exportData(HttpServletResponse response) {
        subjectService.exportData(response);
    }

    @Operation(summary = "课程分类导入",description = "课程分类导入")
    @PostMapping("/importData")
    @ResponseBody
    public ResultData importData(@RequestParam("file") MultipartFile file){
        subjectService.importData(file);
        return ResultData.success(null);
    }
}

